package lanqiao.a2020_b组第二次省赛;

import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        int ans=0;
        for(int i=1;i<=n;i++){
            if(cherk(i)){
                ans+=i;
            }
        }
        System.out.println(ans);

    }
    public  static boolean cherk(int x){
        while (x>0){
            int c=x;
            if(c%10==1||c%10==2||c%10==9||c%10==0){
                return true;
            }
            x=x/10;
        }
        return false;
    }

}
